import { extendApi } from '@inbiz/utils';

type dataList = {
  total: number;
  pageIndex: number;
  searchValue?: string;
  list: {
    [key: string]: string | number | boolean;
  }[];
};

export default extendApi(
  //@ts-ignore
  (_events, props, dataList: dataList, $dataList, $queryData, showFields, $showFields) => {
    return {
      getData: () => {
        return dataList;
      },
      loadData: (value: dataList) => {
        $dataList(value);
      },
      load: (value: any = []) => {
        $queryData(value);
        $dataList((data: any) => {
          return {
            pageIndex: 0,
            total: 0,
            list: [],
          };
        });
      },
    };
  },
);
